package ljl.alg.jianzhioffer.round3.easy;

import commons.ListNode;

public class _18_deleteNode {

    public ListNode deleteNode(ListNode head, int val) {
        ListNode h = new ListNode(0); h.next = head;
        ListNode p = h, cur = head;
        while (cur != null && cur.val != val) {
            p = cur;
            cur = cur.next;
        }
        if (cur != null) {
            p.next = cur.next;
        }
        return h.next;
    }
}
